var express = require("express"),
	query = require("querystring"),
	app = express(),
	str = "",
	Arr = [];
	//设置端口号
	app.listen("2222",function(){
		console.log("服务器已开启,端口号为2222");
	});
	//设置跨域请求
	app.use(function(req,res,next){
		res.header('Access-Control-Allow-Origin','*');
		next();
	});
	
	//注册
	app.post("/zhuce",function(req,res){
		req.on("data",function(data){
			str+=data;
			Arr.push(str);
			console.log(Arr)
		});
		req.on("end",function(){
			Arr.push( query.parse(str) );
			res.send(Arr);	
		});

	});
	
	//登录
	app.get("/login",function(req,res){
		var Bol = "";
		console.log(req.query);
		for(var i = 0; i < Arr.length; i++){
			if(req.query.names == Arr[i].names && req.query.psw==Arr[i].psw){
				Bol = true
			}else{
				Bol = false
			}
		}
		res.send(Bol);
	})
	
	//json;
	app.all("*",function(req,res){
		res.sendFile(__dirname +req.url);
	});
